//
//  YCStoryboardManager.m
//  RobNewGrain
//
//  Created by 唐可雄 on 16/7/25.
//  Copyright © 2016年 swustyc. All rights reserved.
//

#import "YCStoryboardManager.h"

static YCStoryboardManager *manager = nil;

@interface YCStoryboardManager()

/// 键为storyboard的名称，值为storyboard对象
@property (strong, nonatomic) NSMutableDictionary *dic;

@end

@implementation YCStoryboardManager

#pragma mark - Life Cycle

+ (instancetype)sharedInstance {
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        manager = [[YCStoryboardManager alloc] init];
    });
    
    return manager;
}

#pragma mark - Setter and Getter

- (NSMutableDictionary *)dic {
    if (_dic == nil) {
        _dic = [[NSMutableDictionary alloc] init];
    }
    
    return _dic;
}

#pragma mark - Public Methods

+ (UIStoryboard *)storyboardWithName:(NSString *)name {
    UIStoryboard *storyboard = [YCStoryboardManager sharedInstance].dic[name];
    if (storyboard == nil) {
        storyboard = [UIStoryboard storyboardWithName:name bundle:nil];
    }
    
    return storyboard;
}

@end
